@extends('layouts.paymentForm')

@section('content')

<style>
    .od_body .inp_01 {
        border-radius: 0.4rem;
        border: 1px #ccc solid;
        background: #fff;
        line-height: 280%;
        /*margin: 0.3rem auto;*/
        color: #9e9f9f;
        /*width: 77%;*/
        padding: 0 10px;
    }
</style>
<div class="od_box" id="payConfirm">
    <div class="od_body ">
        <form id="balancePayForm">
            <h1>余额支付</h1>
            <h2>将要用钱包余额支付<i class="col02">{{$amount}}元</i><br />再次确认并输入钱包密码</h2>
            <p><input name="wallet_password" type="password" class="inp_01" placeholder="钱包密码"></p>
            <div class="overflow_h"><a onclick="callpay()" class="but03">确定</a><a onclick="history.back()" class="but03">取消</a></div>
        </form>
    </div>
</div>
<script type="text/javascript">

    var trade_number = '{{$trade_number}}';
    var amount = '{{$amount}}';
    var payment_method = '{{$payment_method}}';

    var validator = $("#balancePayForm").validate({
        rules: {
            wallet_password:{
                required:true,
                minlength:6,
                maxlength:20,
                numberAndLetter:true,
                ajax:{url:'{{url('ajax/validate/checkwalletpassword')}}'}
            },
        },
        messages: {
            wallet_password:{
                required:'请输入钱包密码',
                ajax:'钱包密码不正确，请重新输入',
            },
        },
    });

    function callpay()
    {
        if (!validator.form()){
            return;
        }

        var callback = window.callback || function(ret,message){
            alert(message);
            location.href = "{{$redirect_url}}";
        }

        axios.post('/ajax/pay/balancepay', {
            trade_number:trade_number,
        }).then(function (response) {
            if (response.data.code == 200) {
                callback(true,'支付成功');
            } else {
                callback(false,response.data.message || '支付失败');
            }
        },function (response) {
            callback(false,response.data.message || '支付失败');
        }).catch(function (err) {
            callback(false,'支付失败');
        });
    }
</script>
<script type="text/javascript">

    /**
     * 调用提交支付方法
     */
//    callpay();

</script>

@endsection